package com.planet.events;

import java.io.Serializable;

import com.planet.classes.Event;
import com.planet.classes.Events;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ListView;
import android.widget.Toast;

public class EventListActivity extends ListActivity {
	private Events _events;
	@Override
	public void onCreate(Bundle bundle) {
		super.onCreate(bundle);
		Bundle b = getIntent().getExtras();
		Serializable s = b.getSerializable("Events");
		if (s == null) {
			return;
		}
		_events = (Events)s;
		setListAdapter(new EventAdapter(this, _events.getEventList()));
	}
	
	protected void onListItemClick(ListView l, View v, int position, long id) {
		super.onListItemClick(l, v, position, id);
		// Get the item that was clicked
		Event e = (Event)this.getListAdapter().getItem(position);
		Bundle bundle = new Bundle();
        bundle.putSerializable("Event", e);
        Intent newIntent = new Intent(getApplicationContext(), EventDetailsActivity.class);
        newIntent.putExtras(bundle);
        startActivity(newIntent);
	}
}
